package com.example.customviewtest.wymusic;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.example.customviewtest.R;

import java.util.ArrayList;

public class WYMusicListActivity extends AppCompatActivity implements BaseQuickAdapter.OnItemClickListener {

    private RecyclerView mWy_list_rv;
    private ArrayList<MusicBean.AlbumBean.ListBean> mList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wymusic_list);
        Intent intent = getIntent();
        mList = intent.getParcelableArrayListExtra("list");
        mWy_list_rv = findViewById(R.id.wy_list_rv);
        mWy_list_rv.setLayoutManager(new LinearLayoutManager(this));
        WYList2Adapter wyList2Adapter = new WYList2Adapter(this, R.layout.wy_list_item, mList);
        wyList2Adapter.setOnItemClickListener(this);
        mWy_list_rv.setAdapter(wyList2Adapter);

    }


    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        MusicBean.AlbumBean.ListBean listBean = mList.get(position);
        Intent intent = new Intent(WYMusicListActivity.this, PlayMusicActivity.class);
        intent.putExtra("author", listBean.getAuthor());
        intent.putExtra("name", listBean.getName());
        intent.putExtra("poster", listBean.getPoster());
        intent.putExtra("path", listBean.getPath());
        startActivity(intent);
    }
}
